package com.sansan.qiangji.realize.warehouse;

import com.sansan.qiangji.VO.warehouse.taskLog.TaskLogVO;
import com.sansan.qiangji.entity.warehouse.TaskLog;
import com.sansan.qiangji.service.impl.warehouse.TaskLogServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
@Slf4j
public class TaskLogReal {
    private TaskLogServiceImpl taskLogService;

    @Resource
    public void setTaskLogService(TaskLogServiceImpl taskLogService){
        this.taskLogService = taskLogService;
    }

    public List<TaskLogVO> findByStackerTaskCode(String stackerTaskCode){
        List<TaskLogVO> taskLogVOS = new ArrayList<>();
        List<TaskLog> taskLogs = taskLogService.findByStackerTaskCode(stackerTaskCode);
        for (TaskLog taskLog : taskLogs){
            TaskLogVO taskLogVO = new TaskLogVO();
            BeanUtils.copyProperties(taskLog, taskLogVO);
            taskLogVOS.add(taskLogVO);
        }
        Collections.reverse(taskLogVOS);
        return taskLogVOS;
    }
}
